<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('电子发票信息列表')" />
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
<!--                        <li>-->
<!--                            <label style="width: 100px;">直属代理编号：</label>-->
<!--                            <input type="text" name="agentId"/>-->
<!--                        </li>-->
<!--                        <li>-->
<!--                            <label style="width: 100px;">子代理编号：</label>-->
<!--                            <input type="text" name="subAgentId"/>-->
<!--                        </li>-->

                        <li>
                            <label style="width: 100px;">发票金额：</label>
                            <input type="text" name="amount"/>
                        </li>
                        <li>
                            <label style="width: 100px;">发票代码：</label>
                            <input type="text" name="invoiceCode"/>
                        </li>
                        <li>
                            <label style="width: 100px;">纳税人识别号：</label>
                            <input type="text" name="taxpayerNo"/>
                        </li>
                        <li>
                            <label style="width: 100px;">发票号码：</label>
                            <input type="text" name="invoiceNo"/>
                        </li>

                        <li>
                            <label style="width: 100px;">开票时间：</label>
                            <input type="text" name="invoiceTime"/>
                        </li>

                        <li class="select-time">
                            <label style="width: 100px;">添加时间：</label>
                            <input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[startDate]"/>
                            <span>-</span>
                            <input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endDate]"/>
                        </li>
                        <li>
                            <label style="width: 100px;">发票状态：</label>
                            <select name="status">
                                <option value="">所有</option>
                                <option value="-1">代码生成请选择字典属性</option>
                            </select>
                        </li>
                        <li>
                            <label style="width: 10px;"></label>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i> 搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i> 重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-success" onclick="add()" shiro:hasPermission="channel:invoice:add">
                <i class="fa fa-plus"></i> 添加
            </a>
            <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="channel:invoice:edit">
                <i class="fa fa-edit"></i> 修改
            </a>
            <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="channel:invoice:remove">
                <i class="fa fa-remove"></i> 删除
            </a>
            <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="channel:invoice:export">
                <i class="fa fa-download"></i> 导出
            </a>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table" class="table text-nowrap"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer" />
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('channel:invoice:edit')}]];
    var removeFlag = [[${@permission.hasPermi('channel:invoice:remove')}]];
    var prefix = ctx + "channel/invoice";
    var lsChannelStatus = [[${@dict.getType('ls_channel_status')}]];
    $(function() {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            modalName: "电子发票信息",
            firstLoad:false,
            clickToSelect:true,
            columns: [{
                checkbox: true
            },
                {
                    field: 'id',
                    title: '主键',
                    visible: false
                },
                {
                    field: 'agentId',
                    title: '代理编号',
                },
                {
                    field: 'subAgentId',
                    title: '子代理商ID',
                },
                {
                    field: 'source',
                    title: '发票来源',
                    visible: false
                },
                {
                    field: 'operatorName',
                    title: '操作员姓名',
                    visible: false
                },
                {
                    field: 'invoiceCode',
                    title: '发票代码'
                },
                {
                    field: 'taxpayerNo',
                    title: '纳税人识别号'
                },
                {
                    field: 'invoiceNo',
                    title: '发票号码'
                },
                {
                    field: 'taxRatio',
                    title: '税率百分比'
                },
                {
                    field: 'amount',
                    title: '发票金额'
                },
                {
                    field: 'tax',
                    title: '税额'
                },
                {
                    field: 'invoiceTime',
                    title: '开票时间'
                },
                {
                    field: 'invoiceContent',
                    title: '摘要',
                    visible: false
                },
                {
                    field: 'trackingNo',
                    title: '快递单号',
                    visible: false
                },

                {
                    field: 'imagePath',
                    title: '图片',
                    formatter: function (value, row, index) {
                        if (value) {
                            // 添加根路径前缀（如果后端未返回绝对路径）
                            return $.table.imageView(value);
                        }
                        return '暂无图片';
                    },
                },
                {
                    field: 'createtime',
                    title: '添加时间'
                },
                {
                    field: 'status',
                    title: '发票状态',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(lsChannelStatus, value);
                    }
                },
                {
                    field: 'remark',
                    title: '备注'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        if (row.status !== 1) {
                            actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                            actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                            actions.push('<a class="btn btn-info btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="sendChannel(\'' + row.id + '\')"><i class="fa fa-upload"></i>发送</a>');
                        }

                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });
    /* 上送渠道 */
    function sendChannel(id) {
        $.modal.confirm("确认发送渠道请求吗？", function() {
            $.operate.post(prefix + "/sendChannel", { "id": id});
        })
    }
    function  add() {
        $.modal.openFull("新增电子发票信息", prefix + "/add");
    }
</script>
</body>
</html>